# Copyright 2024 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(
    default_visibility = ["//visibility:public"],
    features = [
        "-layering_check",
        "-ctad_warnings",
    ],
)

cc_library(
    name = "hci",
    srcs = [
        "acl_connection.cc",
        "advertising_handle_map.cc",
        "advertising_packet_filter.cc",
        "android_extended_low_energy_advertiser.cc",
        "bredr_connection.cc",
        "bredr_connection_request.cc",
        "connection.cc",
        "discovery_filter.cc",
        "extended_low_energy_advertiser.cc",
        "extended_low_energy_scanner.cc",
        "legacy_low_energy_advertiser.cc",
        "legacy_low_energy_scanner.cc",
        "low_energy_advertiser.cc",
        "low_energy_connection.cc",
        "low_energy_connector.cc",
        "low_energy_scanner.cc",
        "sco_connection.cc",
        "sequential_command_runner.cc",
    ],
    hdrs = [
        "public/pw_bluetooth_sapphire/internal/host/hci/acl_connection.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/advertising_handle_map.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/advertising_packet_filter.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/advertising_report_parser.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/android_extended_low_energy_advertiser.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/bredr_connection.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/bredr_connection_request.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/connection.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/discovery_filter.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/extended_low_energy_advertiser.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/extended_low_energy_scanner.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/legacy_low_energy_advertiser.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/legacy_low_energy_scanner.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/local_address_delegate.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/low_energy_advertiser.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/low_energy_connection.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/low_energy_connector.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/low_energy_scanner.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/sco_connection.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/sequential_command_runner.h",
    ],
    features = ["-conversion_warnings"],
    implementation_deps = [
        "//pw_async:heap_dispatcher",
        "//pw_bluetooth:emboss_hci",
        "//pw_preprocessor",
    ],
    strip_include_prefix = "public",
    tags = ["noclangtidy"],
    deps = [
        "//pw_bluetooth_sapphire/host/common",
        "//pw_bluetooth_sapphire/host/hci-spec",
        "//pw_bluetooth_sapphire/host/transport",
        "//third_party/fuchsia:fit",
    ],
)

cc_library(
    name = "testing",
    srcs = [
        "fake_bredr_connection.cc",
        "fake_local_address_delegate.cc",
        "fake_low_energy_connection.cc",
        "fake_sco_connection.cc",
    ],
    hdrs = [
        "public/pw_bluetooth_sapphire/internal/host/hci/fake_bredr_connection.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/fake_local_address_delegate.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/fake_low_energy_connection.h",
        "public/pw_bluetooth_sapphire/internal/host/hci/fake_sco_connection.h",
    ],
    features = ["-conversion_warnings"],
    strip_include_prefix = "public",
    tags = ["noclangtidy"],
    deps = [
        ":hci",
        "//pw_async:heap_dispatcher",
        "//pw_bluetooth_sapphire/host/common",
    ],
)

pw_cc_test(
    name = "hci_test",
    srcs = [
        "advertising_handle_map_test.cc",
        "advertising_packet_filter_test.cc",
        "connection_test.cc",
        "discovery_filter_test.cc",
        "extended_low_energy_advertiser_test.cc",
        "extended_low_energy_scanner_test.cc",
        "legacy_low_energy_advertiser_test.cc",
        "legacy_low_energy_scanner_test.cc",
        "low_energy_advertiser_test.cc",
        "low_energy_connector_test.cc",
        "low_energy_multiple_advertising_test.cc",
        "low_energy_scanner_test.cc",
        "sequential_command_runner_test.cc",
    ],
    features = ["-conversion_warnings"],
    test_main = "//pw_bluetooth_sapphire/host/testing:gtest_main",
    deps = [
        ":hci",
        ":testing",
        "//pw_bluetooth:emboss_hci_test",
        "//pw_bluetooth_sapphire/host/testing",
        "//pw_bluetooth_sapphire/host/testing:fake_controller",
        "//pw_bluetooth_sapphire/host/testing:gtest_helpers",
        "//pw_bluetooth_sapphire/host/testing:mock_controller",
        "//pw_bluetooth_sapphire/host/testing:test_helpers",
        "//pw_bluetooth_sapphire/host/transport:testing",
    ],
)
